home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / hacklist / 94-05 / text0003.txt < prev    next >
Encoding:
Text File  |  1994-05-19  |  2.8 KB  |  84 lines

  1. > Suppose I have the following application structure:
  2. >         ---------------------
  3. >             my.exe
  4. >         ---------------------
  5. >         |        |
  6. >         |        |
  7. >         |        |
  8. >         ^        ^
  9. >     ------------       ---------------
  10. >     auth.dll        gen.dll
  11. >     ------------       ---------------
  12. >         |        |
  13. >         |        |
  14. >         |        |
  15. >         -----------------
  16. >            winsock.dll
  17. >         -----------------
  18. > Should I call WSAStartup() in my.exe and not in the other two DLLs or 
  19. > should I call it in auth.dll and gen.dll? Can WSACleanup() be called in a 
  20. > wep()? What are the advantages/disavantages?
  21.  
  22. The 1.1 spec clearly states that WSAStartup()/WSACleanup() are used on
  23. per-task basis.  You can call them anywhere in your exe/dlls as long as
  24. you know which task the WSAStartup()/WSACleanup() are referring to.
  25.  
  26. In your setup, I would say do it in my.exe would be easiest.  You can do
  27. it in your dlls too; however, you will have to build a task table to keep 
  28. track of the details.
  29.  
  30. May I suggest you create another DLL that deals with Winsock exclusively
  31. and have your auth.dll and gen.dll interact with it?  It makes thing much 
  32. simpler and clearer.
  33.  
  34. William
  35. --
  36. william@sybase.com
  37. From william@sybase.com Mon May  2 05:14:13 1994
  38. Received: from halon.sybase.com by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  39.           id AA27329; Mon, 2 May 1994 15:13:52 -0400
  40. Received: from sybase.com (sybgate.sybase.com) by halon.sybase.com (5.0/SMI-SVR4/SybFW4.0)
  41.     id AA10741; Mon, 2 May 1994 12:16:40 +0800
  42. Received: from mercury.sybgate.sybase.com (mercury-1) by sybase.com (4.1/SMI-4.1/SybH3.3)
  43.     id AA12227; Mon, 2 May 94 12:13:49 PDT
  44. Received: by mercury.sybgate.sybase.com (4.1/SMI-4.1/SybEC3.2)
  45.     id AA27022; Mon, 2 May 94 12:14:14 PDT
  46. From: william@sybase.com (William Wong)
  47. Message-Id: <9405021914.AA27022@mercury.sybgate.sybase.com>
  48. Subject: Re: Q: How to connect with a timeout ?
  49. To: winsock-hackers@SunSITE.Unc.EDU (Roger Kries)
  50. Date: Mon, 2 May 94 12:14:13 PDT
  51. In-Reply-To: <199404181056.AA20414@SunSITE.Unc.EDU>; from "Roger Kries" at Apr 30, 94 12:07 pm
  52. X-Mailer: ELM [version 2.3 PL0]
  53. Content-Length: 780
  54.  
  55. >  If at the moment of the connect call, the remote machine has no socket
  56. >  created that listens to the specified port, the following select() call
  57. >  will always timeout, even if during the timeout interval a program is
  58. >  started that listens to the port. That means that in the case where a
  59. >  blocking connect call would return ECONNREFUSED, a non-blocking returns
  60. >  WSAWOULDBLOCK, but the select call always timeouts.
  61. > So how can I find out if the remote machine is listening to a specific
  62. > TCP port without blocking and in a Berkley Socket compatible manner?
  63. > Any suggestions are welcome. Thanx in advance.
  64.  
  65. You can always do your own clock counting.  Call select() with zero timeout
  66. in a loop that you do the timeout logic.
  67.  
  68. William
  69. --
  70. william@sybase.com
  71.  
  72.